package com.p2p.auth.service.repository;

import com.p2p.auth.domain.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

/**
 * Created by Antinomy on 16/10/13.
 */

@Repository
public interface UserRepository extends JpaRepository<User, Long> {

    User findByPhoneNum(String phoneNum);

    User findByPhoneNumAndPassWord(String phoneNum, String pwd);

    @Override
    Page<User> findAll(Pageable pageable);

    User findByUserId(String roldId);

    User findByRealName(String realName);

    /**
     * 根据条件分布查询
     * @param userSpecification
     * @param page
     * @return
     */
    Page<User> findAll(Specification<User> userSpecification, Pageable page);

//
//    @Value("${hk.schema}")
//    private String hkSchema;
//
//    @PersistenceContext
//    private EntityManager entityManager;
//
//    @Autowired(required = true)
//    private JdbcTemplate jdbcTemplate;
//
//    User findByPhoneNum(String phoneNum);
//
//    User findByPhoneNumAndPassWord(String phoneNum, String pwd);
//
//    @Override
//    Page<User> findAll(Pageable pageable);
//
//    User findByUserId(String roldId);
//
//    User findByRealName(String realName);
//
//    /**
//     * 根据条件分布查询
//     * @param activitySpecification
//     * @param page
//     * @return
//     */
//    Page<User> findAll(Specification<User> activitySpecification, Pageable page);
}
